package com.my12306.common.controller;

import com.my12306.common.enums.CodeEnum;
import com.my12306.common.util.response.ResponseData;
import com.my12306.train.exception.SeatException;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author:苏牧夕
 * @Date:2020/7/19 0:23
 * @Version 1.0
 */
@RestControllerAdvice
public class ExceptionAdviceController {
    @ExceptionHandler(AuthenticationServiceException.class)
    private ResponseData exception(Exception e) {
        return ResponseData.fail(CodeEnum.FAIL.getCode(), e.getMessage());
    }

    @ExceptionHandler(SeatException.class)
    private ResponseData seatException(Exception e) {
        return ResponseData.fail(CodeEnum.FAIL.getCode(), e.getMessage());
    }
}
